package com.loser.gateway.netty.coder;

import com.loser.gateway.utils.CmdUtils;
import com.loser.module.base.proto.CmdBeanUtils;
import com.loser.module.base.proto.base.InnerResponse;
import com.loser.module.base.proto.base.out.Response;
import com.loser.utils.SerializationUtil;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageEncoder;

import java.util.List;

@ChannelHandler.Sharable
public class ProtostuffEncoder extends MessageToMessageEncoder<InnerResponse> {

    @Override
    protected void encode(ChannelHandlerContext channelHandlerContext, InnerResponse response, List<Object> out) {

        out.add(CmdUtils.merge(response.getTypeCmd(), response.getBytes()));

    }

}
